A pool of objects, allocated in the heap and tracked by their pointers. More...
Public Member Functions | |
| PtrPool (UniquePtr< Allocator< T >> allocator=makeUnique< DefaultAllocator< T >>(), UniquePtr< Deallocator< T >> deallocator=makeUnique< DefaultDeallocator< T >>()) noexcept | |
| PtrPool (const PtrPool &) noexcept=delete | |
| PtrPool (PtrPool &&) noexcept=default | |
| ~PtrPool () | |
| unsigned long long | getPoolSize () const |
| unsigned long long | getFreeItemsCount () const |
| unsigned long long | getFlyingItemsCount () const |
| T * | getObject () |
| void | releaseObject (T *object) |
| PtrPool & | operator= (const PtrPool &) noexcept=delete |
| PtrPool & | operator= (PtrPool &&) noexcept=default |
A pool of objects, allocated in the heap and tracked by their pointers.
Can be used to keep objects around and reusing them many times. This helps in easing memory allocation / deallocation requests, this reducing calls to system.
|
noexcept |
Constructor.
| allocator | Allocator to use when a new object has to be allocated. The pool takes ownership of the allocator provided. |
| deallocator | Deallocator to use when an object has to be freed. The pool takes ownership of the deallocator provided. |
|
deletenoexcept |
Copy constructor.
|
defaultnoexcept |
Move constructor.
| nkMemory::PtrPool< T >::~PtrPool | ( | ) |
Destructor.
| unsigned long long nkMemory::PtrPool< T >::getPoolSize | ( | ) | const |
| unsigned long long nkMemory::PtrPool< T >::getFreeItemsCount | ( | ) | const |
| unsigned long long nkMemory::PtrPool< T >::getFlyingItemsCount | ( | ) | const |
| T* nkMemory::PtrPool< T >::getObject | ( | ) |
| void nkMemory::PtrPool< T >::releaseObject | ( | T * | object | ) |
Returns an object to the pool.
| object | Object to return to the pool. |
|
deletenoexcept |
Copy assignment.
|
defaultnoexcept |
Move assignment.